package org.zpmis.domain.contract.vo;

import lombok.Data;
import org.zpmis.domain.contract.model.ContractTemplate;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

@Data
public class ContractTemplateListVo {
    /**
     * 模板id
     */
    private Long id;

    /**
     * 模板名称
     */
    private String name;

    /**
     * 模板类型 1项目模板 2 入网模板
     */
    private Integer type;

    /**
     * 模板内容
     */
    private String content;

    /**
     * 附件
     */
    private String attachment;

    /**
     * 创建人id
     */
    private Long createId;

    /**
     * 创建人
     */
    private String createPerson;

    /**
     * 创建时间
     */
    private String createTime;

    /**
     * 模版状态 0 禁用 1 启用
     */
    private Integer status;

    public ContractTemplateListVo(ContractTemplate contractTemplate) {
        this.id = contractTemplate.getId();
        this.name = contractTemplate.getName();
        this.type = contractTemplate.getType();
        this.content = contractTemplate.getContent();
        this.attachment = contractTemplate.getAttachment();
        this.createId = contractTemplate.getCreateId();
        this.createPerson = contractTemplate.getCreatePerson();
        this.createTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(contractTemplate.getCreateTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        this.status = contractTemplate.getStatus();
    }
}
